﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="admin_Column_Default"  %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" Runat="Server">
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>栏目
        <small>新闻栏目管理</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="Default.aspx"><i class="fa fa-columns"></i>栏目</a></li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-md-3">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">创建新栏目</h3>
                        </div>
                        <div class="box-body">
                            <div class="form-group">
                                <label class="control-label">栏目</label>
                                <asp:TextBox ID="TextBox1" runat="server" CssClass="form-control" placeholder="栏目名"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="栏目名不可为空" ForeColor="#a94442" ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
                            </div>
                            <div class="form-group">
                                <label class="control-label">描述</label>
                                <asp:TextBox ID="TextBox2" runat="server" CssClass="form-control" placeholder="栏目描述"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="栏目描述不可为空" ForeColor="#a94442" ControlToValidate="TextBox2"></asp:RequiredFieldValidator>
                            </div>
                            <asp:Button ID="Button1" runat="server" Text="创建" CssClass="btn btn-primary" OnClick="Create" />
                        </div>
                    </div>
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">注意</h3>
                        </div>
                        <div class="box-body">
                            每当新增或者删除栏目时，意味着必须要修改前端页面！请谨慎决定。
                        </div>
                    </div>
                </div>
                <div class="col-md-9">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">栏目列表</h3>
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body no-padding">
                            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="True" CssClass="table table-condensed" GridLines="None">
                                <Columns>
                                    <asp:TemplateField HeaderText="#">
                                        <ItemTemplate>
                                            <asp:Label ID="Label2" runat="server" Text='<%# this.GridView1.PageIndex * this.GridView1.PageSize + this.GridView1.Rows.Count + 1%>' />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="栏目名">
                                        <ItemTemplate>
                                            <%# Eval("column_name") %>
                                        </ItemTemplate>
                                        <EditItemTemplate><asp:TextBox ID="TextBox3" runat="server" CssClass="form-control" Text='<%# Eval("column_name") %>'></asp:TextBox></EditItemTemplate>
                                        <ItemStyle Width="20%" />
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="描述">
                                        <ItemTemplate>
                                            <%# Eval("description") %>
                                        </ItemTemplate>
                                        <EditItemTemplate><asp:TextBox ID="TextBox4" runat="server" CssClass="form-control" Text='<%# Eval("description") %>'></asp:TextBox></EditItemTemplate>
                                        <ItemStyle Width="60%" />
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="编辑">
                                        <ItemTemplate>
                                            <asp:HyperLink ID="HyperLink1" NavigateUrl=<%# "~/admin/Column/Default.aspx?edit="+this.GridView1.Rows.Count+"&id="+Eval("id") %> runat="server">编辑</asp:HyperLink>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:LinkButton ID="LinkButton1" runat="server" OnClick="GridView1_RowUpdating" CausesValidation="false">更新</asp:LinkButton>
                                            <asp:LinkButton ID="LinkButton2" runat="server" OnClick="GridView1_RowCancelingEdit" CausesValidation="false">取消</asp:LinkButton>
                                        </EditItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:HyperLink ID="HyperLink2" onclick=<%# "openDialog(" + Eval("id") + ")" %> runat="server" CssClass="cursor">删除</asp:HyperLink>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                        </div>
                    </div>
                </div>
            </div>

            <div id="delModal" class="modal fade" role="dialog" aria-labelledby="delTitle" aria-hidden="true">
                <div class="modal-dialog modal-sm">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                            <h4 class="modal-title" id="delTitle">确认删除吗？</h4>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-primary" onclick="confirm()">确认</button>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="script" Runat="Server">
    <script>
        var del_id;
        function openDialog(id) {
            del_id = id;
            $('#delModal').modal('show');
        }
        function confirm() {
            if (del_id != null) {
                location.href = "/admin/Column/Default.aspx?del_id=" + del_id + "";
            }
        }
    </script>
</asp:Content>

